package com.google.project.client.ProjectManager;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.DockLayoutPanel;
import com.google.gwt.user.client.ui.RootLayoutPanel;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.project.client.Service.LoginService;
import com.google.project.client.Service.LoginServiceAsync;
import com.google.project.client.Sharing.CreateMessage;
import com.google.project.client.Sharing.DailyReportDetail;
import com.google.project.client.Sharing.MessageDetail;
import com.google.project.client.Sharing.MessageList;
import com.google.project.client.Sharing.ProjectReportDetail;
import com.google.project.client.Sharing.ProjectTaskStaff;
import com.google.project.client.Sharing.SelectTask;
import com.google.project.shared.DailyReportDTO;
import com.google.project.shared.MessageDTO;
import com.google.project.shared.ProjectDTO;
import com.google.project.shared.ProjectReportDTO;
import com.google.project.shared.ProjectTaskDTO;

public class PMEntrypoint implements EntryPoint {

	interface ConnectrAppUiBinder extends
			UiBinder<DockLayoutPanel, PMEntrypoint> {
	}

	private static final ConnectrAppUiBinder binder = GWT
			.create(ConnectrAppUiBinder.class);
	private static PMEntrypoint singleton;

	// @formatter:off
	@UiField
	HeaderPanel headerPanel;
	@UiField
	ScrollPanel mainPanel;

	// @formatter:on

	RootLayoutPanel root;

	/** Gets the singleton application instance. */
	public static PMEntrypoint get() {
		return singleton;
	}
	private final LoginServiceAsync loginService = GWT
	.create(LoginService.class);
	@Override
	public void onModuleLoad() {
		singleton = this;
		DockLayoutPanel outer = binder.createAndBindUi(this);
		root = RootLayoutPanel.get();
		root.add(outer);
		mainPanel.add(new PMHomepage());
	}
	public void getUserByID() {
		loginService.getUserName(new AsyncCallback<String>() {

			@Override
			public void onSuccess(String result) {
		//		userName.setHTML("Xin chào:" + result);

			}

			@Override
			public void onFailure(Throwable caught) {
				// TODO Auto-generated method stub

			}
		});
	}
	public void cancelEditFriend() {
		clearMainPanel();
	}

	public void gantt() {
		clearMainPanel();

	}

	public void clearMainPanel() {
		mainPanel.clear();
	}

	public void statisticInformation() {
		clearMainPanel();
		mainPanel.add(new PMHomepage());

	}

	public void PMProjectList() {
		clearMainPanel();
		mainPanel.add(new PMProjectList());
	}

	public void PMProjectDetail() {
		clearMainPanel();
		mainPanel.add(new PMProjectDetail());
	}

	public void PMProjectDetail(String projectId) {
		clearMainPanel();
		mainPanel.add(new PMProjectDetail(projectId));
	}

	public void PMCreateProjectPlan() {
		clearMainPanel();
		mainPanel.add(new PMCreateProjectPlan());
	}

	public void PMCreateProjectPlan(String projectId) {
		clearMainPanel();
		mainPanel.add(new PMCreateProjectPlan(projectId));
	}

	public void PMUpdateProjectInfo() {
		clearMainPanel();
		mainPanel.add(new PMUpdateProjectInfo());
	}

	public void PMUpdateProjectInfo(String projectId) {
		clearMainPanel();
		mainPanel.add(new PMUpdateProjectInfo(projectId));
	}

	public void PMProjectTask() {
		clearMainPanel();
		mainPanel.add(new PMProjectTask());
	}

	public void PMProjectTask(ProjectDTO project) {
		clearMainPanel();
		mainPanel.add(new PMProjectTask(project));
	}

	public void PMProjectTaskStep2(ProjectTaskDTO task, String projectID,int type) {
		clearMainPanel();
		mainPanel.add(new PMProjectTaskStep(task, projectID,type));
	}

	public void PMSubConstructorList() {
		clearMainPanel();
		mainPanel.add(new PMSubConstructorList());
	}

	public void PMCreateSubConstructor(String constructorId,ProjectDTO project) {
		clearMainPanel();
		mainPanel.add(new PMCreateSubConstructor(constructorId,project));
	}

	public void PMCreateSubConstructor() {
		clearMainPanel();
		mainPanel.add(new PMCreateSubConstructor());
	}

	public void PMProjectTask(String taskId, ProjectDTO project) {
		clearMainPanel();
		mainPanel.add(new PMProjectTask(taskId, project));

	}

	public void PMSubConstructorList(ProjectDTO project) {
		clearMainPanel();
		mainPanel.add(new PMSubConstructorList(project));

	}

	public void PMCreateSubConstructor(ProjectDTO project, String action) {
		clearMainPanel();
		mainPanel.add(new PMCreateSubConstructor(project, action));
	}

	public void removeRoot() {
		root.clear();
	}

	public void callPop() {
		clearMainPanel();
		mainPanel.add(new Gantt());
	}

	public void callPop(String projectID) {
		clearMainPanel();
		mainPanel.add(new Gantt(projectID));
	}

	public void PMDailyReportList() {
		clearMainPanel();
		mainPanel.add(new PMDailyReportList());
	}

	

	public void PMDailyReportDetail(DailyReportDTO dailyReportDTO) {
		clearMainPanel();
		mainPanel.add(new DailyReportDetail(dailyReportDTO));
	}

	public void PMProjectStaff(String projectID) {
		clearMainPanel();
		mainPanel.add(new PMProjectStaff(projectID));
	}

	public void PMTaskDetail(ProjectTaskDTO task){
		clearMainPanel();
		mainPanel.add(new PMProjectTaskDetail(task));

	}
	public void PMCreateMessage(){
		clearMainPanel();
		mainPanel.add(new CreateMessage());
	}
	public void PMMessageList(){
		clearMainPanel();
		mainPanel.add(new MessageList());
	}
	
	public void PMMessageDetail(MessageDTO messDTO){
		clearMainPanel();
		mainPanel.add(new MessageDetail(messDTO));
	}

	public void ListDocuments(String forID,String dataType, String projectName, String taskName)
	{
		clearMainPanel();
		mainPanel.add(new DocumentListView(forID, dataType, projectName, taskName));
	}
	public void PMProjectList(int status) {
		clearMainPanel();
		mainPanel.add(new PMProjectList(status));
		
	}
	public void PMCreateProjectReport(ProjectDTO projectDTO){
		clearMainPanel();
		mainPanel.add(new PMCreateProjectReport(projectDTO));
	}
	public void PMProjectReportList(){
		clearMainPanel();
		mainPanel.add(new PMProjectReportList());
	}
	public void PMProjectReportDetail(ProjectReportDTO projectReportDTO){
		clearMainPanel();
		mainPanel.add(new ProjectReportDetail(projectReportDTO));
	}
	public void PMHumanReq(ProjectDTO projectDTO){
		clearMainPanel();
		mainPanel.add(new PMHumanReq( projectDTO));
	}
	public void PMProjectTaskStaff(ProjectTaskDTO task,ProjectDTO project) {
		
		clearMainPanel();
		mainPanel.add(new ProjectTaskStaff(task,project));
		
	}
	public void PMSelectTask(String projectId){
		clearMainPanel();
		mainPanel.add(new SelectTask( projectId));
	}
	public void PMAssignTask(String projectId){
		clearMainPanel();
		mainPanel.add(new PMAssignTask( projectId));
	}
}
